home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / IE7proSetup_2.3.exe / userscripts / YoutubeVideoDownload.ieuser.js < prev   
Text File  |  2008-04-25  |  2KB  |  51 lines

  1. // ==UserScript==
  2. // @name          Download Video from YouTube
  3. // @description   adds a link to download flv from YouTube
  4. // @include       *youtube.com/*v=*
  5. // ==/UserScript==
  6.  
  7. //
  8. // By IE7pro Team
  9. // Ported from http://userscripts.org/scripts/show/3982
  10. //    and from http://userscripts.org/scripts/show/4037
  11. //
  12.  
  13. (function() {
  14.      function in2html(txt)
  15.     {
  16.         if (!txt) return '';
  17.         var txthtml = txt.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
  18.         return(txthtml);
  19.     }
  20.  
  21.     function get_videourl()
  22.     {
  23.         var scriptmedia=new Array();
  24.  
  25.         scriptmedia=document.getElementsByTagName('SCRIPT');
  26.         for(i=0;i<scriptmedia.length;++i) {
  27.             source=scriptmedia[i].text.match(/video_id=\S+&.+&t=.+&/i);
  28.             if (source!=null)
  29.             {
  30.                 return in2html(String(source).replace(/(video_id=.+)&l=.+(&t=.+)&/i,'http:\/\/www.youtube.com\/get_video?$1$2'));
  31.             }
  32.         }
  33.         return "";
  34.     }
  35.  
  36.     //get video url from page source
  37.     var videourl = get_videourl();
  38.     //insert before the vidFacetsDiv
  39.     var elm = document.getElementById("watch-video-details-inner");
  40.     if(!elm) return;
  41.     var elm_parent = elm.parentNode;
  42.  
  43.     var div = document.createElement("div");
  44.  
  45.     elm_parent.insertBefore(div, elm);
  46.  
  47.     div.innerHTML = '<style>#download{text-align:left;margin: 0 10px 0 20px;}.downloadImg{border: 0;float:left;}h2.downloadVid{font-size: 22px;display:inline;}</style><div id="download"><a href="'+videourl+'"><img src="data:image/gif;base64,R0lGODlhFAAUAOYAAP///3jJrvTl4+r38sjp3se0q67i0V2Wd9Xz6gCZZv3+/k2YdgCUX2rDpgCSW3HGqgCZZ2vEpvr9/ACQWf7//v7+/gCWYe/49W7FqPf8+nLGqq3i0Z3YxGPAoVS7mOT07gSXY9Xz62C/oHfJrVG5l02Yde349KXWxI3Ru5XUv4TNtf3z9PT6+QCOVXvLsMayqQCTXt3x6/D59hygcJbVwACVYcrv5HiWfVuUddr17c68tPz+/WrDpQCTXfX8+k6Ydtzx6ur383KSd6/h0uzo5KTayBqicyCmeQCQWK/j0tDs4gCOVvv6+UyXdUyWc5nWwVe8mo/SvAKXYwCWYvX7+eDz7ZHTvWbCo9Hv5tHt5JTVv2rCpJLTvvzy8m3Fp2zEpsbo3VGaeDesgkO0j8fo3fH692WihcLm2gCVX3rKr8Szqdjv6FyWd2m2mPDk4kK0jjethACXZACYZBijdO/59Rykd6aWh1e7mRyebVi8nOr28tHHv9Tu5SSne4TIsAAAACH5BAAAAAAALAAAAAAUABQAAAfygACCg4SFhoIyA4qLjHomFYQZKh08DQ1eD5kYllsRTz6DSh4fCqUZF3QXVKUKZVong2RphBwzdXguhENmK4IEAYQoEzUtV4QGOAK+wINWDAkOEccHygC/hFzPDl/T1dcUginaGILgBtTLAEFQYkdyCXFzcG9AAOfewApRE2gQCRAWkASQYA+dNWYSSMBIwLDHGBaC7qUTtKYPA4BGsgySeJBQERBTpNDoNlHQDhFL8igglIRNNTAjCsW4U6XQBoN8NGBBwBNBCBs5evL0c8ONoApn2jhpsmDBjzBNo5YQYocIoS46XhTYyrWrmj1MDok1FAgAOw==" class="downloadImg"><span class="downloadVid">Download Video</span></a></b></div>';
  48.  
  49. })();
  50.  
  51.